package com.example.sources.jdbc.proxy;

import com.example.sources.util.PropertiesUtil;

import java.sql.*;

/**
 * Created by Administrator on 2016/9/19.
 */
public class SimpleDataSource implements DataSource{
    public String url;
    public String username;
    public String password;

    public SimpleDataSource(){
        url = PropertiesUtil.getProperties("datasource.url");
        username = PropertiesUtil.getProperties("datasource.username");
        password = PropertiesUtil.getProperties("datasource.password");
    }

    @Override
    public Connection getConnection() {
        Connection connecton = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connecton = DriverManager.getConnection(url, username, password);
            //create statement
            Statement statement = connecton.createStatement();
            //execute statement
            PreparedStatement ps;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connecton;
    }
}
